import {Api} from "@/common/api";
import {requestMethod} from "@/common/request";
import {reactive, ref} from "@vue/reactivity";

export const l1DeviceInfoT = reactive({
  stat: {
    icon: "",
    title: "高清摄像头",
    value: 155,
    // unit: "个",
  },
  wrap: [
    {
      title: "设备总数",
      value: 849,
      key: "sxtzs",
    },
    {
      title: "在线数量",
      value: 375,
      key: "sxtzx",
    },
    {
      title: "损坏数量",
      value: 32,
      key: "sxtsh",
    },
  ],
})

export const l1DeviceInfoB = reactive({
  stat: {
    icon: "",
    title: "考勤设备",
    value: 172,
    // unit: "个",
  },
  wrap: [
    {
      title: "设备总数",
      value: 922,
      key: "kq",
    },
    {
      title: "在线数量",
      value: 380,
      key: "kqzx",
    },
    {
      title: "损坏数量",
      value: 23,
      key: "kqsh",
    },
  ],
})

export const l3ColumnData = [
  {
    name: "XM",
    title: "姓名",
  },
  {
    name: "phone",
    title: "联系方式",
  },
  {
    name: "fzfw",
    title: "负责区域",
  },
];

export const l3TableData = ref([
  // {
  //   name: "黄素敏",
  //   phone: "12345678901",
  //   area: "1号宿舍楼-第2周",
  // },
]);

const getRoomInfo = (floor, count, warn, error) => {
  const normal1 = () => ({
    count: 6,
    back: 6,
    noBack: 0,
    lateBack: 0,
    // 宿舍状态
    status: 0,
    members: new Array(6).fill(null).map(() => ({
      name: "陈哲宇",
      // 人员状态
      status: 0,
      image: "https://img.mp.sohu.com/upload/20170512/c106a6f17bf04d7da46084eec1513a3b_th.png",
    })),
  });
  const warn1 = () => ({
    count: 6,
    back: 4,
    noBack: 2,
    lateBack: 0,
    status: 1,
    members: new Array(6).fill(null).map((item, index) => ({
      name: "陈哲宇",
      status: [0, 1, 0, 1, 0, 0][index],
      image: "https://img.mp.sohu.com/upload/20170512/c106a6f17bf04d7da46084eec1513a3b_th.png",
    })),
  });
  const error1 = () => ({
    count: 6,
    back: 2,
    noBack: 2,
    lateBack: 2,
    status: 2,
    members: new Array(6).fill(null).map((item, index) => ({
      name: "陈哲宇",
      status: [1, 2, 2, 0, 1, 0][index],
      image: "https://img.mp.sohu.com/upload/20170512/c106a6f17bf04d7da46084eec1513a3b_th.png",
    })),
  });
  return {
    floor,
    datas: new Array(count).fill(null).map((item, index) => {
      let info = {};
      if (index === warn) {
        info = warn1();
      } else if (index === error) {
        info = error1();
      } else {
        info = normal1();
      }
      info.number = `${floor}${String(index + 1).padStart(2, "0")}`;
      return info;
    }),
  };
};
export const roomListData = [
  getRoomInfo(1, 20, 3, 6),
  getRoomInfo(2, 20, 5, 11),
  getRoomInfo(3, 20, 2, -1),
  getRoomInfo(4, 20, -1, -1),
  getRoomInfo(5, 20, -1, -1),
  getRoomInfo(6, 20, 18, 2),
  getRoomInfo(7, 20, -1, 1),
  getRoomInfo(8, 20, 19, -1),
];

export const r1RoomInfoT = [
  // {
  //   title: "宿舍位置",
  //   value: {
  //     main: "--",
  //   },
  // },
  {
    title: "宿舍规格",
    value: {
      sub: "人寝",
    },
  },
  {
    title: "入住人数",
    value: {
      sub: "人",
    },
  },
];

export const r1RoomInfoB = [
  {
    title: "已归人数",
    value: {
      main: "--",
      sub: "人",
    },
  },
  {
    title: "未归人数",
    value: {
      main: "--",
      sub: "人",
    },
  },
  {
    title: "晚归人数",
    value: {
      main: "--",
      sub: "人",
    },
  },
];

// 考勤数据
export class AttendL2 extends Api {
  constructor() {
    super("api/v1/Kq-count");
    this.method(requestMethod.GET);
  }
}

// 楼表
export class AttendLou extends Api {
  constructor() {
    super("api/v1/Se-oneindex");
    this.method(requestMethod.GET);
  }
}

// 楼详情
export class AttendLouXQ extends Api {
  constructor() {
    super("api/v1/Se-index");
    this.method(requestMethod.GET);
  }
}
// 宿舍基本信息
export class AttendRoom extends Api {
  constructor() {
    super("api/v1/Se-xq");
    this.method(requestMethod.GET);
  }
}
// 宿管人员
export class AttendRoomAdmin extends Api {
  constructor() {
    super("api/v1/sgzb-index");
    this.method(requestMethod.GET);
  }
}
